<template>
	<view>
		<!-- #ifdef APP-PLUS || MP-WEIXIN -->
		<view class="header">
			<uni-nav-bar fixed title="我的音乐" @clickLeft="clickLeft" @clickRight="clickRight">
				<view></view>
				<view slot="left">
					<image src="../../static/image/mine/l.png" mode=""></image>
				</view>
				<view slot="right">
					<image src="../../static/image/mine/r.png" mode=""></image>
				</view>
			</uni-nav-bar>
		</view>
		<scroll-view scroll-y="true" class="body">
			<view class="flex">
				<view class="item" v-for="(item,index) in banner" :key="index">
					<image :src="'/static/image/mine/'+(index+1)+'.png'" mode=""></image>
					<text>{{item.title}}</text>
				</view>
			</view>
			<view class="drawer">
				<view class="item" v-for="(item,index) in drawer" :key="index" @click="handelDrawer(item)">
					<image :src="'../../static/image/mine/m_'+(index+1)+'.png'" mode=""></image>
					<text class="text">{{item.title}}</text>
					<image class="right" src="../../static/image/mine/right.png" mode=""></image>
				</view>
			</view>
			<view class="recommend">
				<view class="title">
					推荐歌单
				</view>
				<view class="rebody">
					<view class="row" v-for="(item,index) in commend" :key="index">
						<view class="item">
							<image :src="item.picUrl" mode=""></image>
							<text>{{item.name}}</text>
						</view>
					</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import uniNavBar from "@/components/uni-nav-bar/uni-nav-bar.vue";
	import service from '../../untils/service.js'
	export default {
		components: {
			uniNavBar
		},
		data() {
			return {
				banner: [{
					title: "私人FM",
					id: 0
				}, {
					title: "最嗨电音",
					id: 1
				}, {
					title: "ACG专区",
					id: 2
				}, {
					title: "Sati空间",
					id: 3
				}, {
					title: "私藏",
					id: 4
				}],
				drawer: [{
					title: "本地音乐",
					id: 0
				}, {
					title: "最近播放",
					id: 1
				}, {
					title: "我的电台",
					id: 2
				}, {
					title: "我的收藏",
					id: 3
				}],
				commend: []
			};
		},
		created() {
			this.getRecommend()
		},
		methods: {
			clickLeft() {
				// console.log('left');
				uni.showToast({
					title: '点击了云',
					duration: 2000
				});
			},
			clickRight() {
				// console.log('right');
				uni.showToast({
					title: '点击了钢琴',
					duration: 2000
				});
			},
			handelDrawer(item) {
				// console.log(item);
			},
			getRecommend() {
				uni.showLoading({
					title: '加载中...'
				});
				uni.request({
					url: service.getRecommend,
					data: {},
					method: 'GET',
					success: (res) => {
						console.log(res.data);
						this.commend = res.data.result
					},
					fail: (err) => {
						uni.showToast({
							title: '网络请求错误',
							icon: 'none',
							duration: 2000
						});
					},
					complete: () => {
						// this.loading = false;
						uni.hideLoading()
					}
				})
			},
		}
	};
</script>
<style lang="scss" scoped>
	.header {
		position: fixed;
		top: 0;
		width: 100%;
		height: 44px;

		image {
			width: 40px;
			height: 30px;
			margin-top: 10px;
		}
	}

	.body {
		position: fixed;
		top: 44px;
		left: 0;
		bottom: 30px;
		right: 0;

		.flex {
			display: flex;
			flex-direction: row;
			margin-top: 10px;
			padding-bottom: 10px;
			border-bottom: 1px solid #eee;

			.item {
				display: flex;
				flex-direction: column;
				flex: 1;
				align-items: center;
				justify-content: center;

				image {
					width: 45px;
					height: 45px;
				}

				text {
					font-size: 14px;
					color: #3F536E;
				}
			}

		}

		.drawer {
			display: flex;
			flex-direction: column;

			.item {
				display: flex;
				flex: 1;
				flex-direction: row;
				padding: 10px 0px 0px 10px;
				border-bottom: 1px solid #ddd;
				align-items: center;
				min-height: 45px;

				image {
					width: 35px;
					height: 30px;
				}

				.text {
					width:150rpx;
					font-weight: 700;
					font-family: cursive;
					margin: 0px 240px 0px 10px;
				}

				.right {
					width: 25px;
					height: 20px;

				}
			}
		}

		.recommend {
			padding: 10px;

			.title {
				font-weight: 700;
			}

			.rebody {
				display: flex;
				flex-flow: row wrap;

				.row {
					flex-direction: column;
					display: flex;
					width: 33.3%;

					.item {
						display: flex;
						flex-direction: column;
						align-items: center;
padding: 10px;
						image {
							width: 100px;
							height: 100px;
							border-radius: 10px;
						}
						text {
							font-size: 12px;
							font-weight: 700;
						}
					}
				}
			}
		}
	}
</style>
